
use "Care_policy_dataset_Rogers"

*** Table descriptives ***
tab poltype country if servicetype=="asylums"
tab poltype country if servicetype=="orphanages"
tab poltype lead if servicetype=="asylums"
tab poltype lead if servicetype=="orphanages"
tab poltype servicetype, column
tab lead poltype if wfregime==1
tab lead poltype if wfregime==2
tab lead poltype if wfregime==3

*** Models ***
mlogit poltype i.lead i.servicedummy, base(1) vce(cluster country)
estimates store basec

mlogit poltype i.lead i.servicedummy i.wfregime gdppc i.coalition i.fed femlab i.instiprov i.prechange, base(1) vce(cluster country)
estimates store controlsc

mlogit poltype i.lead i.servicedummy i.wfregime gdppc i.coalition i.fed femlab i.instiprov i.prechange i.decade, base(1) vce(cluster country)
estimates store fullc

esttab basec controlsc fullc, cells(b(fmt(%9.1f) star) se(par)) stats(N ll aic bic) nobaselevels label

estimates restore fullc
esttab using table_appendix.csv, cells(b(fmt(%9.1f) nostar) se(par)) stats(N ll aic bic) nobaselevels replace plain unstack

*** Marginal change plot ***
mlogit poltype i.lead i.servicedummy i.wfregime gdppc i.fed i.coalition femlab i.instiprov i.prechange i.decade, vce(cluster country) base(1)
mchange lead, stats(ci) level(90)
putexcel set mchange.xlsx, replace
putexcel A1=matrix(r(table)), names
mchangeplot lead, symbols(S M F V) sig(0.1) gap(.2) aspect(1)